# Contributor: Yohann DANELLO <yohann.danello@crans.org>
# Maintainer: Yohann DANELLO <yohann.danello@crans.org>
pkgname=libsrt
pkgver=1.5.0
pkgrel=0
pkgdesc="Secure Reliable Transport (SRT)"
options="!check" # TestMuxer.IPv4_and_IPv6 fail when setting up IPv6
url="https://www.srtalliance.org/"
arch="all"
license="MPL-2.0"
makedepends="cmake openssl-dev linux-headers samurai"
checkdepends="gtest-dev"
subpackages="$pkgname-progs $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/Haivision/srt/archive/v$pkgver.tar.gz
	fix-cmake.patch"
builddir="$srcdir/srt-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DENABLE_UNITTESTS="$(want_check && echo ON || echo OFF)" \
		-DENABLE_TESTING="$(want_check && echo ON || echo OFF)" \
		-DENABLE_STATIC=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	# Broken tests
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

progs() {
	pkgdesc="Tools for working with SRT"
	depends=""
	amove usr/bin
}

sha512sums="
68ab5fe316cfbbbba31b5b2354f657e23c90e14674f8dac01df2bf98c4776a7fafcd690a4dfad3a340e6be577a22360ca04ef2397c8a0dd507adebdd54dc22fb  libsrt-1.5.0.tar.gz
c981710879f1bd83674ed9baeb394e33c5d18af7ca8f3ce92dc683f9d4ec36baeba56bbbc36371ce66d1e65441e33c6b82aecfaa32ee76b2bd9e3dc7feb7b815  fix-cmake.patch
"
